package org.liveboardgames.agricola.control.delegates.action.processor
{
    
    import org.liveboardgames.agricola.model.AgricolaModelLocator;
    import org.liveboardgames.agricola.model.PopupModel;
    import org.liveboardgames.agricola.model.enums.ActionOutputEnum;
    import org.liveboardgames.agricola.vo.action.Action;
    import org.liveboardgames.agricola.vo.common.Target;
    import org.liveboardgames.agricola.vo.player.Player;
    import org.liveboardgames.common.dictionary.collections.IMap;
    
    public class ChooseBuildingMaterialActionProcessor extends ActionProcessor
    {
        public function ChooseBuildingMaterialActionProcessor(action:Action)
        {
            super(action);
        }
        
        override public function execute():void
        {
            var target:Target = action.target;
            if (target is Player)
            {
                var player:Player = target as Player;
                
                // The number of resources that can be taken by the action
                var quantity:int = action.outputQuantity;
                
                // Update the model to tell it that the choose resource popup should be displayed, along with the proper parameters
                AgricolaModelLocator.getInstance().popups.currentActionPopupIndex = PopupModel.POPUP_CHOOSE_RESOURCE_INDEX;
                AgricolaModelLocator.getInstance().popups.numberOfResourcesToTake = quantity;
            }
            else
            {
                throw new Error("not supported target " + target);
            }
        }
    }
}